﻿using UnityEngine;
using System.Collections;

public class statusPlayer: MonoBehaviour
{
	public float currentXP;
	
	public int currentHp ;

	public int currentSave;
	
	public static statusPlayer instance;

	public GUIStyle custonText;

	public float positionX;

	public float positionY;

	public float distance;
	
	// Use this for initialization
	void Start () 
	{    
		//definindo a referencia estática
		instance = this;
	}
	
	// Update is called once per frame
	void Update () 
	{
		//Debug.Log("currentHp = " + currentHp);

	}
	
	//quando matar um montro, eu vou chamar esse metodo e dizer quanto de xp o monstro me deu 
	public void AddXp(float xpAdd)
	{   		
		float newXp =  CurrentDeXP () + xpAdd;
		//currentXP += xpAdd;

		PlayerPrefs.SetFloat ("currentXp", newXp);

	}

	public static float CurrentDeXP ()
	{
		return PlayerPrefs.GetFloat("currentXp");
	}
	
	public void RetHp(int HpRet)
	{
		Debug.Log("currentHP() = " + CurrentHp());
		Debug.Log("HpRet = " + HpRet);

		float vai = CurrentHp() - HpRet;

		Debug.Log("vai = " + vai);


		PlayerPrefs.SetFloat ("currentHp",vai );
	}

	public  float CurrentHp()
	{
		return PlayerPrefs.GetFloat("currentHp", currentHp);
	}

	public void SaveGame(int SG)
	{
		float newSave = CurrentDeSave () + SG;

		PlayerPrefs.SetFloat ("currentSave", newSave);
	}

	public  float CurrentDeSave()
	{
		return PlayerPrefs.GetFloat("currentSave");
	}

		
	void OnGUI()
	{                   // x  y   w   h
		GUI.Label(new Rect(Screen.width * positionX, Screen.height * positionY, 200, 50), "" + CurrentDeXP (), custonText);
		//GUI.Label(new Rect(Screen.width * positionX, Screen.height * (positionY + distance), 200, 50), "currentHp = " + CurrentHp(), custonText);
		//GUI.Label(new Rect(Screen.width * positionX, Screen.height * (positionY + (2*distance)), 200, 50), "currentSave = " + CurrentDeSave (), custonText);
	}

}